var innerStr = '';
// 第一步、获取json数据
var getNav = function() {
	$.get("js/nav.json", function(res) {
		firstNav(res);
		$("nav").html(innerStr);
	});
}
// 第二部、构建一级导航
var firstNav = function(first) {
	for (var i = 0; i < first.length; i++) {
		innerStr += "<dl><dt>" + first[i].name + "</dt><dd>";
		// 渲染二级导航
		secondNav(first[i].next);
		innerStr += "</dd></dl>";
	}
}
// 第三部、构建二级导航
var secondNav = function(second) {
	for (var i = 0; i < second.length; i++) {
		innerStr += "<dl><dt>" + second[i].name + "</dt>"
		// 渲染三级导航
		thirdNav(second[i].next);
		innerStr += "</dl>";
	}
}
// 第四部、构建三级导航
var thirdNav = function(third) {
	for (var i = 0; i < third.length; i++) {
		innerStr += "<dd>" + third[i].name + "</dd>"
	}
}
// 第五步、渲染到DOM当中

getNav();
